import Vue from 'vue';
import VueRouter from 'vue-router';
import BuyersProcess from './BuyersProcess';
import enterProcess from './enterProcess';
import homeProcess from './homeProcess';
import loginSeries from './loginSeries';
import sellerHubProcess from './sellerHubProcess';
import settleInProcess from './settleInProcess';
import tenantCenter from './tenantCenter';

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}


Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('./../views/settleIn/preSettleIn')
  },
  {
    path: '/settleIn',
    redirect: '/settleIn/seeSettleIn',
    component: () => import('../views/settleIn'),
    children: settleInProcess
  },
  {
    path: '/enter',
    redirect: '/enter/enterView',
    component: () => import('../views/enter'),
    children: enterProcess
  },
  {
    path: '/login',
    redirect: '/login/index',
    component: () => import('../views/login/login'),
    children: loginSeries
  },
  {
    path: '/404',
    name: '404',
    component: () => import('../views/errorPage/404')
  },
  {
    path: '/homes',
    redirect: '/homes/homeView',
    component: () => import('../views/homes'),
    children: homeProcess
  },
  {
    path: '/buyers',
    redirect: '/buyers/Buyers',
    component: () => import('../views/buyers'),
    children: BuyersProcess
  },
  {
    path: '/sellerHub',
    redirect: '/sellerHub/sellerHubView',
    component: () => import('../views/sellerHub'),
    children: sellerHubProcess  //子路由  子路由咋了 没事 你继续  知道了
  },
  {
    path: '/tenantCenter',
    redirect: '/tenantCenter/tenantCenterView',
    component: () => import('../views/tenantCenter'),
    children: tenantCenter
  },
  {
    path: '/tenant',
    component: () => import('../views/tenant/tenantInfo')
  },
  // {
  //   path: '/printTest',
  //   component: () => import('../views/Home')
  // },
  // 404 page must be placed at the end !!!
  { path: '*', redirect: '/', hidden: true }
]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router
